#include <stdio.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <unistd.h>
#include <string.h>

int main(){
    struct winsize size;
    memset(&size, 0, sizeof(size));
    while(1){
        sleep(2);
        if(ioctl(STDOUT_FILENO, TIOCGWINSZ, &size) < 0){
            perror("ioctl()");
            exit(1);
        }
        printf("col = %d\n", size.ws_col);
        printf("row = %d\n", size.ws_row);
        printf("xpixel = %d\n", size.ws_xpixel);
        printf("ypixel = %d\n", size.ws_ypixel);
    }
    return 0;
}